using System;
using System.Windows.Forms;
using Krile.Cores;
using Office2007Renderer;

namespace Krile.Subsystem
{
    /// <summary>
    /// Set global props
    /// </summary>
    static class SetGlobal
    {
        /// <summary>
        /// Set toolstrip renderer
        /// </summary>
        static internal void SetRenderer()
        {
            switch (Core.Config.Appearance.ToolStripDesign)
            {
                case Config._Appearance.ToolStripDesigns.Blue:
                    ToolStripManager.Renderer = new Office2007Renderer.Office2007Renderer(new Office2007BlueColorTable());
                    break;
                case Config._Appearance.ToolStripDesigns.Black:
                    ToolStripManager.Renderer = new Office2007Renderer.Office2007Renderer(new Office2007BlackColorTable());
                    break;
                case Config._Appearance.ToolStripDesigns.Silver:
                    ToolStripManager.Renderer = new Office2007Renderer.Office2007Renderer(new Office2007SilverColorTable());
                    break;
                case Config._Appearance.ToolStripDesigns.Professional:
                    ToolStripManager.Renderer = new ToolStripProfessionalRenderer();
                    break;
                default:
                    ToolStripManager.Renderer = new ToolStripSystemRenderer();
                    break;
            }
        }

        static internal void SetDefaultSearchDatas()
        {
            Core.StatusManager.RegistNewSearchData(typeof(Data.TextSearchData));
            Core.StatusManager.RegistNewSearchData(typeof(Data.UserIdSearchData));
            Core.StatusManager.RegistNewSearchData(typeof(Data.UserSearchData));
            Core.StatusManager.RegistNewSearchData(typeof(Data.ServiceIdSearchData));
            Core.StatusManager.RegistNewSearchData(typeof(Data.ServiceSearchData));
        }

        static internal void SetDefaultKeyAssigns()
        {
            sAddACM("SelectAbove");
            sAddACM("SelectBelow");
            sAddACM("SelectNewAbove");
            sAddACM("SelectNewBelow");
            sAddACM("SelectNewestStatus");
            sAddACM("DeselectTimeline");
            sAddACM("EnsureVisibleSelectedStatus");
            sAddACM("JumpInReplyTo");

            sAddACM("ScrollAbove");
            sAddACM("ScrollBelow");
            sAddACM("ScrollEnd");
            sAddACM("ScrollTop");

            sAddACM("DefaultReply");
            sAddACM("DefaultFav");

            sAddACM("AddNewTab");
            sAddACM("AddQuickTab");
            sAddACM("AddTabFromService");
            sAddACM("AddTabFromUser");
            sAddACM("EditSelectedTab");
            sAddACM("CloseSelectedTab");

            sAddACM("OpenPostbox");
            sAddACM("ClosePostbox");

            sAddACM("SelectLeftTab");
            sAddACM("SelectRightTab");

            sAddACM("SetAlreadyReadedAll");
            sAddACM("RefreshTimeline");

            sAddACM("ShowConfig");
            sAddACM("ShowStatusPage");
            sAddACM("ShowUserPage");

            sAddACM("CopyStatus");
            sAddACM("CopyUserID");

            sAddACM("ToggleGlobalTL");
            sAddACM("ToggleTopmost");
        }

        static private void sAddACM(string candidate)
        {
            var delg = System.Delegate.CreateDelegate(
                    typeof(Krilib.Data.Common.KeyAssignCallback),
                    typeof(Data.DefaultKeyAssigns),
                    candidate) as Krilib.Data.Common.KeyAssignCallback;
            if (delg == null)
                throw new InvalidOperationException();
            Core.KeyAssign.AddAssignCandidateMethod(
                delg,
                Lang.KeyAssign.ResourceManager.GetString(candidate));
        }
    }
}
